#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int m;
int e[N], l[N], r[N], idx;

void init() {
	r[0] = 1;
	l[1] = 0;
	idx = 2;
}

void insert(int a, int x) {
	e[idx] = x;
	l[idx] = a, r[idx] = r[a];
	l[r[a]] = idx, r[a] = idx ++ ;
}

void remove(int a) {
	l[r[a]] = l[a];
	r[l[a]] = r[a];
}

int main() {
	cin >> m;
	init();
	while (m -- ) {
		string op;
		cin >> op;
		if (op == "L") {
			int x;
			cin >> x;
			insert(0, x);
		} else if (op == "R") {
			int x;
			cin >> x;
			insert(l[1], x);
		} else if (op == "D") {
			int k;
			cin >> k;
			remove(k + 1);
		} else if (op == "IL") {
			int k, x;
			cin >> k >> x;
			insert(l[k + 1], x);
		} else {
			int k, x;
			cin >> k >> x;
			insert(k + 1, x);
		}
	}
	for (int i = r[0]; i != 1; i = r[i])
		cout << e[i] << ' ';
	cout << endl;

	return 0;
}
